package br.com.cast.base;

import java.sql.Connection;

import javax.mail.Session;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


public class DaoBase {

	@PersistenceContext(unitName="persistencia")
	private EntityManager entityManeger;
	
	protected Connection conexao;

	protected Connection getConnection() {

		if (conexao == null) {
//			try {
//				conexao = dataSource.getConnection();
//				
//			} catch (SQLException e) {
//				e.printStackTrace();
//				throw new RuntimeException("Erro para Criar Conexão");
//			}
		}
		return conexao;
	}
	
	protected EntityManager getEntidyManager(){
		return this.entityManeger;
	}
	
	protected Session getHibernateCurrentSession(){
		return(Session) getEntidyManager().getDelegate();
	}
}
